import 'package:flutter/material.dart';

//表格布局
class TableWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: new AppBar(
          title: new Text("Table"),
          leading: new BackButton(),
        ),
        body: new Table(
          //设置每一列的宽度。
          columnWidths: const <int, TableColumnWidth>{
            0: FixedColumnWidth(50),
            1: FixedColumnWidth(100),
            2: FixedColumnWidth(50),
            3: FixedColumnWidth(100),
          },
          /* 每一个cell的垂直方向的alignment。
        top：被放置在的顶部；
        middle：垂直居中；
        bottom：放置在底部；
        baseline：文本baseline对齐；
        fill：充满整个cell */
          defaultVerticalAlignment: TableCellVerticalAlignment.bottom,
          border: TableBorder.all(
              color: Colors.grey, width: 1, style: BorderStyle.solid),
          children: const <TableRow>[
            TableRow(children: <Widget>[
              Text('A1'),
              Text('B1'),
              Text('C1'),
              Text('D1'),
            ]),
            TableRow(children: <Widget>[
              Text('A2'),
              Text('B2'),
              Text('C2'),
              Text('D2'),
            ]),
            TableRow(children: <Widget>[
              Text('A3'),
              Text('B3'),
              Text('C3'),
              Text('D3'),
            ]),
          ],
        ));
  }
}
